package print;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Set;
import java.util.function.Consumer;

public class PropertiesDemo2 {


    public static void main(String[] args) throws IOException {
        Properties pt=new Properties();
        pt.setProperty("username","lose");
        pt.setProperty("age","20");
        pt.setProperty("heigth","176cm");
        System.out.println(pt);
        final var strings = pt.stringPropertyNames();
        for (String key : strings) {
            System.out.println(key+pt.get(key));
        }
        strings.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s+"---"+pt.getProperty(s));
            }
        });
        FileOutputStream fos=new FileOutputStream("G:\\Javatest2\\print\\config2.properties");
        pt.store(fos,"cxq");
        System.out.println(pt);
        FileInputStream fis=new FileInputStream("G:\\Javatest2\\print\\config2.properties");
        pt.load(fis);
        System.out.println(pt);




    }
}
